package com.pds.web.app.controller;

import com.pds.common.core.domain.R;
import com.pds.web.app.service.IAppStationOpsService;
import com.pds.web.company.domain.PdsCompanyStationOpsForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * app端站房运维功能
 */
@RestController
@RequestMapping("/appStation")
public class AppStationOpsController {

    @Autowired
    IAppStationOpsService appStationOpsService;

    /**
     * 新建运维表单
     * @param form
     *          - stationId：站房id
     *          - type 1：废水，2：废气
     *          - tableType 表单类型：字典值
     *                          废水表单类型 water_table_type
     *                          废气表单类型 gas_table_type
     */
    @PostMapping("createForm")
    public R createForm(@RequestBody PdsCompanyStationOpsForm form) {
        form = appStationOpsService.createForm(form);
        return R.ok(form);
    }

    /**
     * 查询运维表单详情
     * @return
     */
    @GetMapping("getFromDetail")
    public R getFromDetail(@RequestParam("id") Long id) {
        PdsCompanyStationOpsForm form = appStationOpsService.getFromDetail(id);
        return R.ok(form);
    }

    /**
     * 运维签到签退
     * @param map
     *         - id 运维表单id
     *         - type 1签到 2 签退
     *         - fileId 拍照照片id
     *         - place 经纬度
     * @return
     */
    @PostMapping("checkIn")
    public R checkIn(@RequestBody Map map) {
        appStationOpsService.checkIn(map);
        return R.ok();
    }

    /**
     * 提交台账
     * @param map
     *          - id 运维表单id
     *          - ledgerId 台账附件id
     * @return
     */
    @PostMapping("formSumit")
    public R formSumit(@RequestBody Map map){
        appStationOpsService.formSumit(map);
        return R.ok();
    }

    /**
     * 删除表单
     * @param id
     * @return
     */
    @GetMapping("deleteForm")
    public R deleteForm(@RequestParam("id") Long id){
        appStationOpsService.deleteForm(id);
        return R.ok();
    }

    /**
     * APP首页：工作情况、待办
     * @param type week本周、month本月、year本年
     * @return
     */
    @GetMapping("getIndexData")
    public R getIndexData(@RequestParam("type") String type){
        Map map = appStationOpsService.getIndexData(type);
        return R.ok(map);
    }

}
